<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['set']=$this->plugin_setting('basic');
$keywords=$this->plugin_setting('search');
if($_RQ['op']=='main'){
	$return['params']=array();
	$return['list']=array();
	set_html('title','全部拍卖活动');
	$return['sharedata']=array(
		'title'=>$return['setting']['share_title']?'全部商品'.$return['setting']['share_title']:'全部拍卖活动-降价拍',
		'desc'=>$return['setting']['share_desc']?$return['setting']['share_desc']:'降价拍！',
		'link'=>custom_url('jy_weishop_cutprice/list/fromuser='.$_SESSION['uid'],true),
		'imgUrl'=>ATTACHMENT_URL.$setting['share_image']
	);
	exi($return);
}
// js 获取数据
if($_RQ['op']=='getlist'){
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'status'=>1,
	);
	if(trim($_RQ['keywords'])){
		$params['title like']='%'.trim($_RQ['keywords']).'%';
	}

	//进一步整理筛选条件，商品属性字段是否需 要调整，商品分类如何筛选，orderby如何整理
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	if($_RQ['num']){
		$psize=$_RQ['num'];
	}
	$total='';
	$fields=array('id','uniacid','goodsid','title','images','original','startprice','stopprice','cuttime','cutprice','only_member','total','starttime','status');
	$orderby='id desc ';
	$list=pdo_getslice('jy_weishop_cutprice_act',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	
	//获取商品活动信息
	if($list){
		foreach($list as &$item){
			$item['goods']=pdo_get('jy_weishop_goods',array('id'=>$item['goodsid']));
			$images=json_decode($item['images'],true);
			$item['image']=$images['0'];
		}
	}
	$return['list']=$list;
	$return['order']=$_RQ['order'];
	$return['url']=custom_url('jy_weishop/goods.index/getlist/',true);
	//print_r($list);exit;
	exi($return);
}	
?>